﻿<%@ WebHandler Language="C#" Class="getAttendencePlace" %>

using System;
using System.Web;
using Wicresoft.Common;
using System.Data;
using System.Text;

public class getAttendencePlace : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        HttpResponse Response = context.Response;
        HttpRequest Request = context.Request;
        Response.ContentType = "text/plain";
        StringBuilder sb =new StringBuilder();
        sb.Append("[");
        string where = "";
        if (!string.IsNullOrEmpty(Request["deptName"]) && Request["deptName"].Trim().Length>0)
        {
            where = string.Format(" where Place like '%{0}%' ", Request["deptName"]);
        }
        DataTable dt = DataAccess.ExecuteSql("Attendences.ConnectionString", "select distinct Place from Attendence " + where + " order by Place").Tables[0];
        if (dt != null && dt.Rows.Count > 0)
        {
            foreach (DataRow dr in dt.Rows)
            {
                sb.Append("'");
                sb.Append(dr["Place"].ToString());
                sb.Append("'");
            }
        }
        sb.Append("]");
        Response.Write(sb.ToString());
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}